package com.heima.admin.controller;

import com.heima.api.wemedia.WemediaClient;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.NewsAuthDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequiredArgsConstructor
public class WmNewsAuditController {

    private final WemediaClient wemediaClient;

    /**
     * 分页查询根据状态和标题
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/news/list_vo")
    public PageResponseResult listByStatusAndTitle(@RequestBody NewsAuthDto dto){
        log.info("分页查询根据状态和标题:{}",dto);
        PageResponseResult result = wemediaClient.listByStatusAndTitle(dto);
        return result;
    }

    /**
     * 根据id查询新闻
     * @return
     */
    @GetMapping("/api/v1/news/one_vo/{id}")
    public ResponseResult quireById(@PathVariable Integer id){
        log.info("根据id查询文章:{}",id);
        return wemediaClient.quireById(id);
    }


    @GetMapping("/test/{id}")
    public ResponseResult test(@PathVariable Integer id){
        log.info("trest");
        return ResponseResult.okResult(null);
    }

    /**
     * 人工审核:审核不通过
     * @return
     */
    @PostMapping("/api/v1/news/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto){
        log.info("审核通过");
        return wemediaClient.authFail(dto);
    }

    /**
     * 人工审核:审核通过
     * @return
     */
    @PostMapping("/api/v1/news/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto){
        log.info("审核不通过");
        return wemediaClient.authPass(dto);
    }

}
